﻿#include "FITKPHengLEISolverManager.h"
#include "FITKPHengLEIData.h"
#include "FITKPHengLEISolverSubsonic.h"
#include "FITKPHengLEISolverTransonic.h"
#include "FITKPHengLEISolverSupersonic.h"
#include "FITKPHengLEISolverHypersonic.h"
#include "FITKPHengLEISolverIncompressible.h"
#include "FITK_Kernel/FITKCore/FITKEnumTransformer.hpp"
#include "FITKPHengLEISolverManager.h"

namespace Interface
{
    FITKPHengLEISolverManager::FITKPHengLEISolverManager()
    {
        this->initSolvers();
    }

    FITKPHengLEISolverManager::~FITKPHengLEISolverManager()
    {

    }

    FITKPHengLEISolverInfo FITKPHengLEISolverManager::getSolverInfoBySolverName(QString solverName)
    {
        for (QList<FITKPHengLEISolverInfo>::iterator iter = m_solvers.begin(); iter != m_solvers.end(); ++iter)
        {
            if ((*iter)._solverName == solverName) return *iter;
        }
        return FITKPHengLEISolverInfo();
    }

	QStringList FITKPHengLEISolverManager::getSolvers()
	{
		QStringList sovlers;
		for (QList<FITKPHengLEISolverInfo>::iterator iter = m_solvers.begin();iter!= m_solvers.end();++iter)
		{
			sovlers.append(iter->_solverName);
		}
		return sovlers;
	}


    void FITKPHengLEISolverManager::initSolvers()
    {
        //Subsonic求解器
        FITKPHengLEISolverInfo infoSubsonic;
		infoSubsonic._solverName = "Subsonic";
		infoSubsonic._solverType = FITKPHengLEIAbsSolver::PHengLEISolverType::PLSubsonic;
		infoSubsonic._createFuns = [&] {return new FITKPHengLEISubsonicSolver; };
        m_solvers.append(infoSubsonic);

        //Transonic求解器
        FITKPHengLEISolverInfo infoTransonic;
		infoTransonic._solverName = "Transonic";
		infoTransonic._solverType = FITKPHengLEIAbsSolver::PHengLEISolverType::PLTransonic;
		infoTransonic._createFuns = [&] {return new FITKPHengLEITransonicSolver; };
        m_solvers.append(infoTransonic);

		//Supersonic求解器
		FITKPHengLEISolverInfo infoTSupersonic;
		infoTSupersonic._solverName = "Supersonic";
		infoTSupersonic._solverType = FITKPHengLEIAbsSolver::PHengLEISolverType::PLSupersonic;
		infoTSupersonic._createFuns = [&] {return new FITKPHengLEISupersonicSolver; };
		m_solvers.append(infoTSupersonic);

		//Hypersonic求解器
		FITKPHengLEISolverInfo infoHypersonic;
		infoHypersonic._solverName = "Hypersonic";
		infoHypersonic._solverType = FITKPHengLEIAbsSolver::PHengLEISolverType::PLHypersonic;
		infoHypersonic._createFuns = [&] {return new FITKPHengLEIHypersonicSolver; };
		m_solvers.append(infoHypersonic);

		//Incompressible求解器
		FITKPHengLEISolverInfo infoIncompressible;
		infoIncompressible._solverName = "Incompressible";
		infoIncompressible._solverType = FITKPHengLEIAbsSolver::PHengLEISolverType::PLIncompressible;
		infoIncompressible._createFuns = [&] {return new FITKPHengLEIIncompressibleSolver; };
		m_solvers.append(infoIncompressible);
    }

    

}